<script src="web/assets/plugins/bootstrap-select2/select2.min.js" type="text/javascript"></script>
<script src="web/assets/plugins/jquery-datatable/js/jquery.dataTables.min.js" type="text/javascript" ></script>
<script src="web/assets/js/table_configuracion.js" type="text/javascript"></script>
<script src="./fuentes/view/pokerSpecific/js/script_ajax_poker_specific.js" type="text/javascript"></script>
<script src="web/assets/js/validadores_numericos.js" type="text/javascript"></script> 

<div class="clearfix"></div>
<div class="content">  

    <!-- Modal -->
    <div class="modal fade" id="myModalPokerSpecificADD" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 id="myModalLabel" class="semi-bold">Participantes</h4>

                </div>

                <div class="modal-body">

                    <form  action="./fuentes/controller/PokerSpecific.php" id="formPokerSpecific" name="formPokerSpecific" autocomplete="off" > 
                        <?php require_once '/FormPokerSpecific.php'; ?>

                    </form> 

                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
    </div>


    <div class="row" id="movimiento">
        <div class="col-md-12">
            <div class="grid simple ">
                <div class="grid-title no-border" style="padding: 14px 15px 40px 15px;">
                    <div class="col-md-5" >
                        <h4 ><span class="semi-bold">Lista de Participantes </span></h4>

                    </div>
                    <div class="col-md-7" >
                        <span   class="col-md-8" >
                            <input type="hidden" name="torneoIdList"  id="torneoIdList"  class="form-control" value="<?php echo $torneoIdList; ?>" >
                            <select class="form-control" id="cmbTorneoList" name="cmbTorneoList">
                                <?php
                                if ($pokerTorneos) {
                                    foreach ($pokerTorneos as $datoC) {
                                        if ($torneoIdList == $datoC["id"]) {
                                            echo " <option  value='" . $datoC["id"] . "'  selected='true'  >" . $datoC["nombre"] . "</option>";
                                        } else {
                                            echo " <option  value='" . $datoC["id"] . "'>" . $datoC["nombre"] . "</option>";
                                        }
                                    }
                                } else {
                                    echo " <option class='select2-results' value='0'>NO EXISTE TORNEOS ACTIVOS</option>";
                                }
                                ?>

                            </select>

                        </span>
                        <span   class="col-md-4" >
                            <input type="hidden" name="tipoListado"  id="tipoListado"  class="form-control" value="<?php echo $tipoListado; ?>" >
                            <select class="form-control" id="cmbTipoListado" name="cmbTipoListado">
                                <option value="INSCRIPTOS" <?php if ($tipoListado == 'INSCRIPTOS') echo "selected"; ?> >INSCRIPTOS</option>
                                <option value="PREINSCRIPTOS" <?php if ($tipoListado == 'PREINSCRIPTOS') echo "selected"; ?> >PRE INSCRIPTOS</option>
                                <option value="TODAS" <?php if ($tipoListado == 'TODAS') echo "selected"; ?> >TODAS</option>
                            </select>

                        </span>

                        <!--                    <button style="float: right;" class="btn btn-success btn-xs " id="agregar" data-toggle="modal"  data-target="#myModalPokerSpecificADD"> Agregar</button>-->

                        <div class="labelRight" id="error">	</div>
                    </div>
                </div>
                <div class="grid-body no-border">

                    <table class="table table-hover no-more-tables table-condensed  " id="pokerSpecificTABLE">
                        <thead>
                            <tr>
                                <th style="width:1%">Id </th>
                                <th style="width:20%">Nombre </th>
                                <th class='text-center' style="width:4%">Documento</th>
                                <th class='text-center' style="width:2%">Mesa</th>
                                <th class='text-center' style="width:2%">Posición</th>
                                <th class='text-center' style="width:5%">Estado</th>
                                <th class='text-center' style="width:10%;">Acción</th>

                            </tr>
                        </thead>
                        <tbody id="pokerSpecificList">
                            <?php
                            if ($pokerSpecifics) {
                                foreach ($pokerSpecifics as $dato) {

                                    echo getColorEstado($dato["estado"]);
                                    echo "<td>" . $dato["id"] . "</td>"
                                    . "<td>" . $dato["apenom"] . "</td>"
                                    . "<td class='text-center'>" . $dato["documento"] . "</td>"
                                    . "<td class='text-center'>" . $dato["mesa_numero"] . "</td>"
                                    . "<td class='text-center'>" . $dato["mesa_posicion"] . "</td>"
                                    . "<td class='text-center'>" . $dato["estado"] . "</td>"
                                    . "<td class='text-center'>";
                                    if ($dato["id"] == 0) {
                                        echo "<button class='btn btn-success btn-xs btn-mini' onclick='inscribirDato(" . $dato["persona_id"] . ")' title='Preinscribir' ><i class='fa fa-flag'></i></button>
                                             <button class='btn btn-default btn-xs btn-mini' title='Eliminar' ><i class='fa fa-times'></i></button>
                                             <button class='btn btn-default btn-xs btn-mini' title='Movimiento' ><i class='fa fa-random'></i></button>";
                                    } else {
                                        if ($dato["estado"] == "PRE INSCRIPTO") {
                                            echo "
                                                <button class='btn btn-default btn-xs btn-mini' title='Editar' ><i class='fa fa-pencil'></i></button>";
                                        } else {
                                            echo "
                                                <button class='btn btn-success btn-xs btn-mini' onclick='editDatos(" . $dato["persona_id"] . ")' title='Editar' ><i class='fa fa-pencil'></i></button>";
                                        }

                                        if ($dato["estado"] == "PRE INSCRIPTO") {
                                            echo "
                                                <button class='btn btn-success btn-xs btn-mini' onclick='eliminarDato(" . $dato["id"] . ")' title='Eliminar' ><i class='fa fa-times'></i></button>";
                                        } else {
                                            echo "
                                                <button class='btn btn-default btn-xs btn-mini' title='Eliminar' ><i class='fa fa-times'></i></button>";
                                        }
                                        echo "
                                            <button class='btn btn-success btn-xs btn-mini' onclick='pokerMovimientoByPersona(" . $dato["persona_id"] . ")' title='Movimiento' ><i class='fa fa-random'></i></button>";
                                    }

                                    echo "</td>"
                                    . "</tr>";
                                }
                            }

                            function getColorEstado($estado) {
                                $res = "<tr>";
                                if ($estado) {
                                    switch ($estado) {
                                        case 'PRE INSCRIPTO': $res = " <tr class='warning'>";
                                            break;
                                        case 'ELIMINADO': $res = " <tr class='danger'>";
                                            break;
                                        case 'DESCALIFICADO': $res = " <tr class='danger'>";
                                            break;
                                        default: $res = " <tr class='success'>";
                                            break;
                                    }
                                }

                                return $res;
                            }

                            function getIcono($yes) {
                                if ($yes)
                                    return "<i class='fa fa-pencil'></i>";
                                else
                                    return "<i class='fa fa-flag'></i>";
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!-- END PAGE --> 
</div>




